<template>
  <div class="news-item__container" :class="{ 'no_border': isLast }" @click="sa.go(item.nextUrl)">
    <div class="news-item__title">
      <el-tag v-if="item.ranking < 4" type="danger" size="mini" effect="dark">
        热
      </el-tag>
      <div>{{ item.title }}</div>
    </div>
    <div class="news-item__hotspot" v-if="item && item.hotSpot !== undefined">
      {{ formatNumber(item.hotSpot)}}
    </div>
  </div>
</template>

<script>
import numberFunc from '@/mixins/number';
export default {
  name: 'NewsItem',
  props: {
    item: Object,
    isLast: Boolean
  },
  mixins: [numberFunc],
}
</script>

<style lang="scss" scoped>
@import '@/styles/mixin.scss';

/* 容器样式 */
.news-item__container {
  @include flex-between;
  width: 100%;
  min-width: 0;
  gap: 12px;
  border-bottom: 1px solid #f0f2f5;
  padding: 8px;
  transition: background-color 0.2s ease;
}

.news-item__container {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.news-item__container:hover {
  background-color: #f5f7fa;
  transform: translateX(4px);
  
  .news-item__title div {
    color: #409eff;
  }
  
  .news-item__hotspot {
    color: #606266;
  }
}

.no_border {
  border-bottom: none;
}

/* 标题区域 */
.news-item__title {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;

  div {
    flex: 1;
    font-size: 14px;
    color: #303133;
    line-height: 1.5;
    cursor: pointer;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    transition: color 0.2s ease;
  }
}

/* 热点数值 */
.news-item__hotspot {
  height: 100%;
  font-size: 12px;
  color: #909399;
  min-width: 0;
  text-align: right;
  margin-left: 8px;
}

/* 热标签 */
.el-tag {
  height: 18px;
  line-height: 18px;
  padding: 0 4px;
}
</style>
